//
//  CFRechargeViewController.m
//  CFfuturestalent
//
//  Created by 子yu 刘 on 2018/4/27.
//  Copyright © 2018年 子yu 刘. All rights reserved.
//

#import "CFRechargeViewController.h"
#import "CFRechareRecordVC.h"
#import "CFCorfimePayVC.h"

@interface CFRechargeViewController ()

@end

@implementation CFRechargeViewController{
    UIButton * _lastMoneyBtn;
    UIButton * _lastPayBtn;
    NSString * _money;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUpUI];
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem barBtnItemWithTitle:@"充值记录" target:self action:@selector(topUpRecords)];
    [[self.tfMoney rac_signalForControlEvents:UIControlEventEditingChanged] subscribeNext:^(__kindof UIControl * _Nullable x) {
        UITextField * tf = (UITextField *)x;
        self->_money= [tf.text
         stringByReplacingOccurrencesOfString:@"$" withString:@""];
        tf.text = [NSString stringWithFormat:@"$%@",self->_money];
    }];

}

- (void)setUpUI{
    self.btnMoney1.layer.borderColor = [UIColor colorWithHexString:@"00a0e9"].CGColor;
    self.btnMoney2.layer.borderColor = [UIColor colorWithHexString:@"00a0e9"].CGColor;
    self.btnMoney3.layer.borderColor = [UIColor colorWithHexString:@"00a0e9"].CGColor;
    [self.tfMoney setValue:[UIColor colorWithHexString:@"687278"]
                forKeyPath:@"_placeholderLabel.textColor"];
}

- (void)topUpRecords{
    CFRechareRecordVC * recordVC = (CFRechareRecordVC *)[CFUtility getVC:@"CFRechareRecordVC" Storyboard:MINE];
    [self.navigationController pushViewController:recordVC animated:YES];
}

- (IBAction)chooseMoney:(UIButton *)sender {
    [sender setBackgroundColor:[UIColor colorWithHexString:@"00a0e9"]];
    [sender setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.tfMoney.text = sender.titleLabel.text;
    if (![_lastMoneyBtn isEqual:sender]) {
        [_lastMoneyBtn setBackgroundColor:[UIColor clearColor]];
         [_lastMoneyBtn setTitleColor:[UIColor colorWithHexString:@"00a0e9"] forState:UIControlStateNormal];
    }
    _lastMoneyBtn = sender;
    
}

- (IBAction)choosePayWay:(UIButton *)sender {
    [sender setImage:[UIImage imageNamed:@"选中"] forState:UIControlStateNormal];
    if (![_lastPayBtn isEqual:sender]) {
         [_lastPayBtn setImage:[UIImage imageNamed:@"未选中"] forState:UIControlStateNormal];
    }
    _lastPayBtn = sender;
}

- (IBAction)next:(id)sender {
    CFCorfimePayVC * corfimeVC = (CFCorfimePayVC *)[CFUtility getVC:@"CFCorfimePayVC" Storyboard:MINE];
    [self.navigationController pushViewController:corfimeVC animated:YES];
}


@end
